<?php
namespace app\common\builder\button;
class Custom
{
    /**
     * @param string $title 按钮标题
     * @param string $position 位置
     * @return array 生成样式
     * 自定义按钮样式
     * @date：2020/5/6
     */
    public static function button($title='',$position='')
    {
        if($title=='details' and $position=='right'){
            $data=[
                'title' => '详情',
                'icon'  => 'fa fa-fw fa-search-plus',
                'class' => 'btn btn-xs btn-default ajax-get',
                'href'  => url('details', ['id' => '__id__'])
            ];//右侧详情
        }
        else if($title=='reply'){
            $data=[
                'title' => '回复',
                'icon'  => 'fa fa-fw fa-comments',
                'class' => 'btn btn-xs btn-default ajax-get',
                'href'  => url('reply', ['id' => '__id__'])
            ];//右侧回复
        }
        else if ($title=='agree'){
            $data = [
                'title' => '同意',
                'icon'  => 'fa fa-fw fa-check',
                'class' => 'btn btn-primary ajax-post confirm',
                'href'  => url('agree'),
                'target-form' =>'ids',
            ];//顶部同意
        }
        else if ($title=='refuse'){
            $data = [
                'title' => '拒绝',
                'icon'  => 'fa fa-fw fa-times',
                'class' => 'btn btn-danger ajax-post confirm',
                'href'  => url('refuse'),
                'target-form' =>'ids',
            ];//顶部拒绝
        }else if($title=='recharge'){
            $data=[
                'title' => '充值',
                'icon'  => 'glyphicon glyphicon-copyright-mark',
                'class' => 'btn btn-default js-get',
                'href'  => url('recharge'),
                'target-form' =>'ids',
            ];//右侧详情
        }
        else if($title=='send' and $position=='right'){
            $data=[
                'title' => '确认发货',
                'icon'  => 'fa fa-fw fa-gift ',
                'class' => 'btn btn-xs btn-primary ajax-get',
                'href'  => url('send', ['id' => '__id__'])
            ];//右侧发货
        }
        else if($title=='confir' and $position=='right'){
            $data=[
                'title' => '确认出库',
                'icon'  => 'fa fa-fw fa-gift',
                'class' => 'btn btn-xs btn-default ajax-get',
                'href'  => url('confir', ['id' => '__id__'])
            ];//右侧发货confirm
        }
        else if($title=='retreat' and $position=='right'){
            $data=[
                'title' => '确认退款',
                'icon'  => 'fa fa-fw fa-sign-in',
                'class' => 'btn btn-xs btn-default ajax-get',
                'href'  => url('retreat', ['id' => '__id__'])
            ];//右侧退款
        }
        else if($title=='collect' and $position=='right'){
            $data=[
                'title' => '确认收货',
                'icon'  => 'fa fa-fw fa-shopping-basket',
                'class' => 'btn btn-xs btn-default ajax-get',
                'href'  => url('collect', ['id' => '__id__'])
            ];//右侧收货
        }
        else if($title=='attr' and $position=='right'){
            $data=[
                'title' => '编查属性',
                'icon'  => 'fa fa-fw fa-low-vision',
                'class' => 'btn btn-xs btn-default ajax-get',
                'href'  => url('attr', ['id' => '__id__'])
            ];//右侧收货
        }
        else if($title=='attr_sku' and $position=='right'){
            $data=[
                'title' => '添加该商品属性售价库存',
                'icon'  => 'fa fa-fw fa-plus-circle',
                'class' => 'btn btn-xs btn-default ajax-get',
                'href'  => url('attr_sku', ['id' => '__id__'])
            ];//右侧收货
        }
        else if($title=='excel'){
            $data=[
                'title' => '导出',
                'icon'  => 'fa fa-fw fa-list-alt',
                'class' => 'btn btn-primary js-get',
                'href'  => url('excel'),
                'target-form' => 'ids',
            ];//顶部导出excel
        }
        return $data;
    }

    //订单号
    public static function order_sn() {
        $year_code = array('A','B','C','D','E','F','G','H','I','J');//年份
        $order_sn = $year_code[intval(date('Y'))-2020].
            strtoupper(dechex(date('m'))).date('d').
            substr(time(),-5).substr(microtime(),2,5).sprintf('d',rand(0,99));
        return $order_sn;
    }

}